import request from '@/utils/request'
// import qs from 'qs'

// neighbor表

// 获取neighbor列表
export function getNeighborArray (params) {
  var data = fromData(params)
  return request({
    url: 'neighbor/getNeighborArray',
    method: 'post',
    data
  })
}

// 清空neighbor列表
export function cleanNeighbor (params) {
  var data = fromData(params)
  return request({
    url: 'neighbor/clean_neighbor',
    method: 'post',
    data
  })
}

// 增加信息
export function addNeighbor (params) {
  var data = fromData(params)
  return request({
    url: 'neighbor/addInfo',
    method: 'post',
    data
  })
}

// 删除信息
export function delNeighbor (params) {
  var data = fromData(params)
  return request({
    url: 'neighbor/del_info',
    method: 'post',
    data
  })
}

// 修改信息
export function editNeighbor (params) {
  var data = fromData(params)
  return request({
    url: 'neighbor/editInfo',
    method: 'post',
    data
  })
}

// function fromData (params) {
//   var data = qs.stringify(params)
//   return data
// }

function fromData (params) {
  let formData = new FormData()
  for (const it in params) {
    if (!Object.is(params[it], null) && !Object.is(params[it], '')) {
      formData.append(it, params[it])
    }
  }
  return formData
}
